import { useRouterStore } from '../store/router'
import { useTabBarStore } from '../store/layout/tabBar'
import { RouteRecordRaw } from 'vue-router'
import { TabBarListItemType } from '@/framework/types/layout'

export const initRouterAndTabBar = (
  layoutViews: Array<RouteRecordRaw>,
  publicViews: Array<RouteRecordRaw>,
  tabBarList: Array<TabBarListItemType>,
  afterLoginHandler?: () => Promise<any>
) => {
  const routerStore = useRouterStore()
  const tabBarStore = useTabBarStore()
  routerStore.addPublicRoutes(publicViews)
  routerStore.addLayoutRoutes(layoutViews)
  tabBarStore.setTabBarList(tabBarList)
  afterLoginHandler && routerStore.setAfterLoginHandler(afterLoginHandler)
}
